import { Button } from 'antd';
import { ExportOutlined } from '@ant-design/icons';

import * as APIS from '../../../../constants/api-constants';

interface ExportProps {
  currentTemplateUuid: string | undefined,
  currentQuestionnaireUuid: string | undefined,
  isExportDisable: boolean
}

export default ({
  currentTemplateUuid,
  currentQuestionnaireUuid,
  isExportDisable
}: ExportProps) => (
  <>
    <Button
      type="primary"
      disabled={isExportDisable}
      icon={<ExportOutlined />}
      onClick={() => {
        window.open(
          `${APIS.DOWNLOAD_EXPORT_EXCEL}/?templateUuid=${currentTemplateUuid}&questionnaireUuid=${currentQuestionnaireUuid}`
        );
      }}
    >
      导出
    </Button>
  </>
);
